home *** CD-ROM | disk | FTP | other *** search
- Path: hubcap.clemson.edu!hubcap!mjs
- From: mjs@hubcap.clemson.edu (M. J. Saltzman)
- Newsgroups: comp.lang.pl1,comp.lang.c
- Subject: Re: PL/I and C
- Date: 23 Feb 96 22:05:39 GMT
- Organization: Clemson University
- Message-ID: <mjs.825113139@hubcap>
- References: <4gh5ru$eng@goanna.cs.rmit.EDU.AU> <312CCEB2.4AB7@corp.dialog.com> <AD536AAB9668B76CD@mcdialb09.it.luc.edu> <312E363C.3CDE@corp.dialog.com>
- NNTP-Posting-Host: hubcap.clemson.edu
-
- Paul Gorodyansky <paul_gorodyansky@corp.dialog.com> writes:
-
- |Verne Arase wrote:
- |>
- |> In article <312CCEB2.4AB7@corp.dialog.com>,
- |> Paul Gorodyansky <paul_gorodyansky@corp.dialog.com> wrote:
- |>
- |> >In PL/I, you can consider your source record as a string,
- |> >or as SEVERAL different complex Structures, using Based variables.
- |> >C has it, too, but with a BIG limitation - if you want to put
- |> >SEVERAL different 'masks' over your buffer, C allows ONLY simple
- |> >variables as items of these structures, not Arrays !
- |>
- |> Actually, this is incorrect.
- |>
- |> In fact, if I recall correctly a pointer to x is implicitly an array.
-
- I don't understand this remark at all. A pointer to x is nothing like
- an array. See the FAQ for a detailed discussion of the relationship
- between pointers and arrays.
-
- |Sorry, you missed my point. If I want to have SEVERAL masks for THE SAME
- |area of memory, that is have SEVERAL DIFFERENT Structures overlaid my
- |buffer, C has a feature for this - a Union, where I can have members of
- |different Nature overlaid the same area of memory, BUT, unlike PL/I, an
- |Array CAN NOT be a member of a Union. But, it is always a case in our
-
- This is a vicious lie (or at very least, an unfortunate
- misconception). A field in a union can be anything that a field in a
- struct can be, incuding a bitfield.
-
- |Text Processing - I want to look at my source record's buffer at some
- |----
- |point of time, as at a structure like this:
- | 1 Patent_Info,
- | 2 Part_1,
- | 3 Patent_Number ...
- | 3 Date_Of_Application...
- | ...
- | 2 Part_5,
- | 3 Opponents, or 3 Opponents(10),
- | 4 Name(10)... 4 Name...
- | 4 Address(10)... 4 Address
- |
- |In C I CAN NOT do it, so I MUST find some 'work around' and my code's
-
- union {
- struct {
- char patent_number[10];
- char date_of_application[6];
- } part_1;
-
- /* ... */
-
- struct {
- struct {
- char name[80];
- char address[4][80];
- } opponent[10];
- } part_5;
- } patent_info;
-
- /* ... */
-
- puts(patent_info.part_5.opponent[3].name);
-
- |logic become more complex, less clear, and far from SPECS, because this
- |structure was given in SPECS. So, next person who will work his FIRST
- |time with this code, will have trouble.
- --
- Matthew Saltzman
- Clemson University Math Sciences
- mjs@clemson.edu
-